package com.fz.us.oa.core.dao.com.impl;

import com.fz.us.admin.company.bean.FlowEnum;
import com.fz.us.admin.company.dao.impl.BaseFlowDaoImpl;
import com.fz.us.oa.core.dao.com.OrderEntityDao;
import com.fz.us.oa.core.entity.com.OrderEntity;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by ZhuChunXiao on 2017/7/19.
 */
@Repository
public class OrderEntityDaoImpl extends BaseFlowDaoImpl<OrderEntity, String> implements OrderEntityDao {
    @Override
    public boolean checkOrderNo(String orderNo, String keyId) {
        String hql="from OrderEntity o where o.orderNo=? and o.processState!=? and o.id!=?";
        List<OrderEntity> orderEntities = getSession().createQuery(hql)
                .setParameter(0,orderNo)
                .setParameter(1, FlowEnum.ProcessState.Draft)
                .setParameter(2,keyId).list();
        if(orderEntities.size()>0){
            return false;
        }else{
            return true;
        }
    }
}
